package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 答疑 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=1010;
       static class Pair implements Comparable<Pair>{
    	      int s,a,e;
    	      Pair(int s,int a,int e){
    	    	   this.s=s;
    	    	   this.a=a;
    	    	   this.e=e;
    	      }
			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
				return (this.s+this.a+this.e)-(o.s+o.a+o.e);
			}
       }
			static Pair[]s=new Pair[N];
			static int n;
			public static void main(String[] args) throws IOException {
				    n=Integer.parseInt(br.readLine());
				    for(int i=0;i<n;i++){
				    	String[]ss=br.readLine().split(" ");
				    	s[i]=new Pair(Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2]));
				    }
				    Arrays.sort(s, 0,n);
				    long t=0,res=0;
				    for(int i=0;i<n;i++){
				    	res+=s[i].a+s[i].s+t;
				    	t+=s[i].a+s[i].s+s[i].e;
				    }
				    System.out.print(res);
			
       }
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
 
       //暴搜
       /*static Pair s[]=new Pair[N];
       static int n;
       static boolean st[]=new boolean[N];
       
       static int dfs(int d,int re){
    	      if(d==n)return 0;
    	      int min=Integer.MAX_VALUE;
    	      for(int i=0;i<n;i++){
    	    	  if(!st[i]){
    	    		  st[i]=true;
    	    		  min=Math.min(min,dfs(d+1,re+s[i].e+s[i].a+s[i].s)+s[i].a+s[i].s);
    	    		  st[i]=false;
    	    	  }
    	      }
    	      return min+re;
       }
       public static void main(String[] args) throws NumberFormatException, IOException {
		      n=Integer.parseInt(br.readLine());
		      for(int i=0;i<n;i++){
		    	  String[]ss=br.readLine().split(" ");
		           s[i]=new Pair(Integer.parseInt(ss[0]),Integer.parseInt(ss[1]),Integer.parseInt(ss[2]));			  
		      }
		      System.out.print(dfs(0,0));
	}*/
    		   
}
